[Codegen][CPU] Fold reshape-containing encoding relayouts to map_store.#24533
Merged
Conversation
5 tasks
c531378 to
3a9e9b4
Compare
egebeysel
approved these changes
Jun 5, 2026
egebeysel
left a comment
Contributor
There was a problem hiding this comment.
Thanks, LGTM in general, just 2 questions 😄
GPU's configuration pipeline folds the `pack`/`expand_shape`/`transpose` relayout chain from encoding materialization into a single `iree_linalg_ext.map_store` before tiling; CPU did not. For a non-row- major encoding swizzle the intervening `tensor.expand_shape` (not a `TilingInterface` op) blocks producer fusion and strands an untiled, whole-tensor `pack` intermediate. Mirror GPU on CPU: - Add `RelayoutCombinationScope::DispatchReshape`: like `Dispatch` but restricted to chains whose backward slice contains an expand/collapse_shape. Pure pack/unpack/transpose chains tile fine and are left alone. - Run `CombineResultLayoutTransformation` with that scope in the CPU configuration pipeline, after MaterializeDeviceEncoding. - Skip `map_load`/`map_store` as `getRootOperation` candidates, so a dispatch with a real compute op plus a `map_store` roots on the compute op. Inert for existing (row-major) CPU encodings. Progress towards #24515. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Benoit Jacob <jacob.benoit.1@gmail.com>
3a9e9b4 to
5a6b922
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GPU's configuration pipeline folds the
pack/expand_shape/transposerelayout chain from encoding materialization into a singleiree_linalg_ext.map_storebefore tiling; CPU did not. For a non-row- major encoding swizzle the interveningtensor.expand_shape(not aTilingInterfaceop) blocks producer fusion and strands an untiled, whole-tensorpackintermediate.Mirror GPU on CPU:
RelayoutCombinationScope::DispatchReshape: likeDispatchbut restricted to chains whose backward slice contains an expand/collapse_shape. Pure pack/unpack/transpose chains tile fine and are left alone.CombineResultLayoutTransformationwith that scope in the CPU configuration pipeline, after MaterializeDeviceEncoding.map_load/map_storeasgetRootOperationcandidates, so a dispatch with a real compute op plus amap_storeroots on the compute op.Inert for existing (row-major) CPU encodings.
Progress towards #24515.